home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / libs / sphigs / sph_srgp.lha / srgp / src / srgp_error.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-09  |  4.2 KB  |  126 lines

  1. #include "HEADERS.h"
  2. #include "srgplocal.h"
  3.  
  4.  
  5. #ifdef X11
  6. static
  7. char *(srgp_errmsgs[]) =
  8.   {
  9.    "UNUSED",
  10.    "The canvas table is full: your attempt to create a canvas is ignored.\n",
  11.    "You may not delete the screen canvas -- its life is too valuable!\n",
  12.    "You may not delete the canvas which is currently active.\n",
  13.    "SRGP is already enabled!  You can't reinitialize or change table sizes.\n",
  14.    "SRGP is not enabled yet!  Have you heard about SRGP_begin() ?\n",
  15.    "You sent a bad rectangle (%d,%d,%d,%d) (either your l>r, or your b>t).\n",
  16.    "You sent a bad font index (%d) (either negative or too large).\n",
  17.    "You sent a bad font index (%d) (that entry of font-table is undefined).\n",
  18.    "You sent a bad count (%d) (it was negative).\n",
  19.    "You sent a bad line-style spec (%d) (please use our named constants).\n",
  20.    "You sent a bad marker-style spec (%d) (please use our named constants).\n",
  21.    "You sent a bad write-mode spec (%d) (please use our named constants).\n",
  22.    "SRGP_setColorTable: The %s of the range of pixel values you specified (%d)\n\tlies outside this machine's LUT.\n",
  23.    "You sent a bad fill-style spec (%d) (please use our named constants).\n",
  24.    "You sent a bad pattern index (%d).\n",
  25.    "You sent a bad cursor index (%d).\n",
  26.    "No known canvas possesses the index you sent.\n",
  27.    "You sent a bad input device spec (%d).\n",
  28.    "You sent a bad input mode spec (%d).\n",
  29.    "You did a 'get' on a device that was NOT responsible\n\tfor the last wait_event exit.\n",
  30.    "Whoops!  Event queue is full!  We tossed an event into oblivion...\n",
  31.    "You sent a bad locator-echo type (%d) (please use our named constants).\n",
  32.    "You sent a bad keyboard-processing mode (%d) (please use our named constants).\n",
  33.    "You sent a list of %d points (either too many or too few).\n",
  34.    "You sent a bad font filename (%s).\n",
  35.    "I ran out of dynamic memory while allocating tables or creating a new canvas.\n",
  36.    "NOT IMPLEMENTED YET!!!!\n",
  37.    "X SERVER ERROR\n  (examining the core will be useful only if using X in synchronous mode):\n\t %s\n",
  38.    "You sent a bad line-width spec (%d).\n",
  39.    "You tried to get me to use an EMPTY entry in the pattern table.\n",
  40.    "You sent a negative or zero marker size (%d).\n",
  41.    "There is no more memory available for pix/bitmap pattern entries!\n"
  42.  
  43.    "UNUSED"
  44. };
  45.  
  46. static char logmessage[] =
  47. "%s FATAL ERROR:\n\
  48.    %s\
  49. \n\nI AM ABOUT TO INTENTIONALLY CRASH SO YOU CAN LOOK\n\
  50.       AT THE ACTIVATION STACK USING A DEBUGGER.\n\n\
  51. If your application is an SRGP application, please remember:\n\
  52.    If the error message above says\n\
  53.    that you sent a bad argument to a certain function,\n\
  54.    you should run your program with tracing ON in order\n\
  55.    to see exactly what you sent.\n\
  56. If you already had tracing enabled, remember to look in\n\
  57.    'SRGPlogfile' for the tracing messages.\n\n";
  58.    
  59. char **srgp__identifierOfMessages = srgp_errmsgs;
  60. #endif
  61.  
  62.  
  63. #ifdef THINK_C
  64. static char logmessage[] = "%s FATAL ERROR:\n   %s\n";
  65.  
  66. int srgp__identifierOfMessages = 128;
  67. #endif
  68.  
  69.  
  70.  
  71.  
  72. #ifdef THINK_C
  73. void SRGP__cleanupMacMemory (void);
  74. #endif
  75.  
  76. static int zero = 0;
  77.  
  78. char *srgp__identifierOfPackage = "SRGP";
  79.  
  80. void
  81. SRGP__error (errtype, arg1, arg2, arg3, arg4, arg5)
  82. int errtype, arg1, arg2, arg3, arg4, arg5;
  83. {
  84.    int item;
  85.    char processedmessage[400];
  86. #ifdef THINK_C
  87.    char rawmessage[256];
  88. #endif
  89. #ifdef X11
  90.    char *rawmessage;
  91. #endif
  92.  
  93.    /* SIMPLE HANDLING??? */   
  94.    if (srgp__curErrHndlMode == NON_FATAL_ERRORS) {
  95.       SRGP_errorOccurred = errtype;
  96.       return;
  97.    }
  98.  
  99.    /* DETERMINE THE MESSAGE CORRESPONDING TO THE ERROR TYPE */
  100. #ifdef THINK_C
  101.    GetIndString (rawmessage, srgp__identifierOfMessages, errtype);
  102.    PtoCstr(rawmessage);
  103. #endif
  104. #ifdef X11
  105.    rawmessage = srgp__identifierOfMessages[errtype];
  106. #endif
  107.  
  108.    sprintf (processedmessage, rawmessage, arg1, arg2, arg3, arg4, arg5);
  109.  
  110. #ifdef X11
  111.    fprintf (stderr, logmessage, srgp__identifierOfPackage, processedmessage);
  112. #endif
  113. #ifdef THINK_C
  114.    SRGP__cleanupMacMemory();
  115.    CtoPstr(processedmessage);
  116.    CtoPstr(srgp__identifierOfPackage);
  117.    ParamText (srgp__identifierOfPackage,processedmessage,NULL,NULL);
  118.    if ((item=StopAlert (8811, NULL)) == 5)
  119.       exit (0/zero);  /* will crash here intentionally */
  120.    DisposeWindow (srgpmac__cwindow);
  121.    ExitToShell();
  122. #else
  123.    abort ();
  124. #endif
  125. }
  126.